define(function() {
    return ['$scope','$location', '$interval','$timeout','bizProxy','$log','$cacheFactory','$anchorScroll', function($scope,$location,$interval,$timeout,bizProxy,$log,$cacheFactory,$anchorScroll) {
    	$scope.$emit('flag-tag','2'); 	//显示顶部部文字

    	//默认值
    	$scope.lawyerFeeShow = false;//律师费
    	$scope.xsCaseShow = false;//刑事案件
    	var caseListData ={};
    	//存储数据对象
    	var tempCaseList = _YHC_TOOL.caseListJson;
    	for(var i=0;i< tempCaseList.length;i++){
    		caseListData[tempCaseList[i].name] = tempCaseList[i];
    	}
    	// console.log(caseListData["上海"].name)
		
		$scope.conditionData ={
			caseName:"民事案件",
			cityName: "上海"
		}
		$scope.targetAmount = '';
		var cityJsonList = _YHC_TOOL.toolCityList;

		//监听标的额
		$scope.$watch('targetAmount', function(newValue, oldValue, scope) {
			if($scope.targetAmount != "" && $scope.targetAmount != null){
				$scope.showClear = true;
				$scope.lawyerFeeShow = true;
				$scope.hanziNum = _YHC_TOOL.numToHanzi($scope.targetAmount);
				var caseData = caseListData[$scope.conditionData.cityName];
				$scope.lawyerFee = _YHC_TOOL.getlayyerFee(caseData.qjList,caseData.minData,$scope.targetAmount,caseData.qjFlag,caseData.containFlag);
			}else{
				$scope.showClear = false;
				$scope.lawyerFeeShow = false;
				$scope.hanziNum = '';
				$scope.lawyerFee = "";
			}
			
			// console.log(getlayyerFee(tempArray,"1000-3000",8800000,true,true))
		});

		//点击清空标的
		$scope.clearNum = function(){
			$scope.targetAmount = "";
			$scope.lawyerFeeShow = false;
			$scope.hanziNum = '';
			$scope.lawyerFee = "";
			$scope.showClear = false;
		}


		//显示案件列表
		$scope.showCaseList = function(){
			$scope.isShow = true;
			$timeout(function() {
				$scope.isslide_up = true;
			}, 100);
		}

		//点击取消
		$scope.selectCase = function(flag){
			$scope.isslide_up = false;
			$timeout(function() {
				$scope.isShow = false;
			}, 100);
			if($scope.conditionData.caseName == "刑事案件"){
				if(flag == '1' || flag == '2'){
					$scope.xsCaseShow = false;
					$scope.lawyerFeeShow = false;
					$scope.targetAmount = "";
				}
			}else{
				if(flag == '3'){
					$scope.xsCaseShow = true;
					$scope.lawyerFeeShow = false;
					var caseData = caseListData[$scope.conditionData.cityName];
                	$scope.zcjdData = caseData.zcjd;
	                $scope.scjdData = caseData.scqsjd;
	                $scope.spjdData = caseData.spjd;
				}
			}

			if(flag == '1'){
				$scope.conditionData.caseName = "民事案件";
			}else if(flag == '2'){
				$scope.conditionData.caseName = "行政案件";
			}else if(flag == '3'){
				$scope.conditionData.caseName = "刑事案件";
			}
		}

		//点击显示城市列表
		$scope.showCityList = function(){
			$scope.$emit('flag-tag','3'); 	//显示顶部部文字
			$scope.isCityShow = true;
			$scope.cityJsonList = cityJsonList;
			$timeout(function() {
				$scope.isCityListShow = true;
			}, 100);
		}

        //取消城市列表
        $scope.cancleCitylist = function(city){
        	$scope.$emit('flag-tag','2'); 	//显示顶部部文字
            $scope.isCityListShow = false;
            $timeout(function() {
                $scope.isCityShow = false;
                $scope.conditionData.cityName = city;
                var caseData = caseListData[$scope.conditionData.cityName];
                if($scope.conditionData.caseName == "刑事案件"){
                	$scope.zcjdData = caseData.zcjd;
	                $scope.scjdData = caseData.scqsjd;
	                $scope.spjdData = caseData.spjd;
                }else{
                	$scope.lawyerFee = _YHC_TOOL.getlayyerFee(caseData.qjList,caseData.minData,$scope.targetAmount,caseData.qjFlag,caseData.containFlag);
                }
            }, 200);
        }

        //监听取消城市列表
        $scope.$on('dowmCityList', function(){
            $scope.$emit('flag-tag','2'); 	//显示顶部部文字
            $scope.isCityListShow = false;
            $timeout(function() {
                $scope.isCityShow = false;
            }, 200);
        });

        //监听取消介绍列表
        $scope.$on('dowmDetContent', function(){
            $scope.$emit('flag-tag','2'); 	//显示顶部部文字
            $scope.isBzDetShow = false;
            $timeout(function() {
                $scope.isBzShow = false;
            }, 200);
        });

        //点击显示介绍信息
        $scope.showIntroduce = function(){
        	$scope.$emit('flag-tag','4'); 
        	$scope.$emit("title-name",$scope.conditionData.cityName + "律师收费标准");
        	$scope.isBzShow = true;
            $timeout(function() {
                $scope.isBzDetShow = true;
            }, 200);
        	var caseData = caseListData[$scope.conditionData.cityName];
            $scope.contentDet = caseData.content;

        }

        $scope.$apply();
    }];
});